package com.centriole.common.enums;

/**
 * 功能描述：流程类型枚举
 *
 * @author 胥原
 * @date 2018-05-16 17:27
 */
public enum FlowTypeEnum {

    EMPLOYEE("员工", "employee"),
    DEPARTMENT("部门", "department"),
    CLIENT("客户", "client"),
    PROVIDER("供应商", "provider"),
    MATERIAL("物料", "material"),
    ENCODE("编码规则", "encode");
    //表名类型
//    EMPLOYEE_TABLE("员工", "md_employee"),
//    DEPARTMENT_TABLE("部门", "md_department"),
//    CLIENT_TABLE("客户", "md_client"),
//    PROVIDER_TABLE("供应商", "md_provider"),
//    MATERIAL_TABLE("物料", "md_material"),
//    ENCODE_TABLE("编码规则", "md_encode");

    // 成员变量
    private String name;
    private String code;

    // 构造方法
    FlowTypeEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    //覆盖方法
    @Override
    public String toString() {
        return this.code + "_" + this.name;
    }

    /**
     * 根据code获取名称
     *
     * @param code 数字
     * @return 含义
     */
    public static String getNameByCode(String code) {
        for (FlowTypeEnum entity : FlowTypeEnum.values()) {
            if (entity.getCode().equals(code)) {
                return entity.getName();
            }
        }
        return "";
    }
}
